package com.ruoyi.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.bean.BeanUtils;
import com.ruoyi.system.domain.FyProjectPlan;
import com.ruoyi.system.domain.vo.business.FyProjectApplyAllPassListDto;
import com.ruoyi.system.domain.vo.business.FyProjectApplyAndPlanSelectListVO;
import com.ruoyi.system.domain.vo.business.FyProjectPlanSelectListVO;
import com.ruoyi.system.mapper.FyProjectPlanMapper;
import com.ruoyi.system.service.IFyProjectPlanService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * 扶垚项目进度上报
 *
 * @author ruoyi
 * @date 2024-02-28
 */
@Service
public class fyProjectPlanServiceImpl extends ServiceImpl<FyProjectPlanMapper, FyProjectPlan> implements IFyProjectPlanService {
    @Autowired
    private FyProjectPlanMapper fyProjectPlanMapper;


    @Override
    public List<FyProjectPlanSelectListVO> list(Long fyProjectApplyId) {
        LambdaQueryWrapper<FyProjectPlan> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(fyProjectApplyId != null, FyProjectPlan::getFyProjectApplyId, fyProjectApplyId);
        List<FyProjectPlan> fyProjectPlans = fyProjectPlanMapper.selectList(wrapper);
        ArrayList<FyProjectPlanSelectListVO> list = new ArrayList<>();
        for (FyProjectPlan fyProjectPlan : fyProjectPlans) {
            FyProjectPlanSelectListVO vo = new FyProjectPlanSelectListVO();
            BeanUtils.copyBeanProp(vo, fyProjectPlan);
            list.add(vo);
        }
        return list;
    }

    /*
    获取所有扶摇项目列表，再根据项目id获取申报进度，再进行数据封装
     */
    @Override
    public List<FyProjectApplyAllPassListDto> getByPlanList() {

        return null;
    }

    @Override
    public List<FyProjectApplyAndPlanSelectListVO> getListByUserIdAndProjectId(Long fyProjectApplyId, Long userId) {

        return fyProjectPlanMapper.selectListByUserIdAndProjectId(fyProjectApplyId, userId);
    }

}
